import { inject, observer } from 'mobx-react';
import classname from 'classnames';
import { toJS } from 'mobx';
import { Button, Modal } from 'antd';
import {
  WeaDialog,
  WeaSearchGroup,
  WeaFormItem,
  WeaRightMenu,
  WeaSelect,
  WeaTab,
  WeaLocaleProvider,
  WeaButtonIcon,
  WeaNewScroll,
  WeaDatePicker,
} from 'ecCom';
import { WeaSwitch, WeaTableNew, WeaLogView } from 'comsMobx';

const { WeaTable } = WeaTableNew;
const { confirm } = Modal;
const WeaLogViewComp = WeaLogView.Component;
const getLabel = WeaLocaleProvider.getLabel;
import CoworkRichText from '../../../public/CoworkRichText';
import CoworkConstant from '../../../util/CoworkConstant';
import * as CoworkUtil from '../../../util/CoworkUtil';
import NewAuth from './NewAuth';
import DefalutJoiner from './DefalutJoiner';

const coworkEngineNewPlateKey = 4; // 调用后端新建版块的key

@inject('coworkStoreMap', 'coworkMainStore')
@observer
export default class NewCowork extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      showLog: false,
      targetId: '',
      selectQuit: [],
    };
  }

  componentDidMount() {
    let initAddQuery =
      this.props.initAddQuery === undefined ? {} : this.props.initAddQuery;
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    coworkNewStore.doInit(initAddQuery);
    if (!window.weaCoworkEngine) {
      // 新建协作要抛出去，所有要单独加载下
      // 异步加载别模块的静态资源
      setTimeout(() => {
        eventRegister.loadModule(
          'b_cowork',
          () => {
            coworkNewStore.setLoaded(true);
          },
          () => {
            // 加载文件失败 的业务处理， 网络超时，没文件之类
          },
          200,
        );
      });
    } else {
      coworkNewStore.setLoaded(true);
    }
  }

  componentWillReceiveProps() {
    if (this.props.random === undefined) {
    } else {
      let initAddQuery =
        this.props.initAddQuery === undefined ? {} : this.props.initAddQuery;
      const coworkNewStore = this.props.coworkStoreMap.getMapStore(
        this.props.storeMapKey,
      );
      coworkNewStore.doInit(initAddQuery);
    }
  }

  onTypIdChange = (v) => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    coworkNewStore.setCreateState({ selectValue: v });
    coworkNewStore.getAccessoryPath(v);
    // 解决版块从无到有的选择：提醒未选择的问题
    coworkNewStore.createForm.updateFields({ typeId: v });
  };

  onTypeIdAddClick = () => {
    if (window.weaCoworkEngine) {
      const coworkEngineStoreMap =
        window.weaCoworkEngine.store &&
        window.weaCoworkEngine.store.coworkEngineStoreMap;
      const coworkPlateSetStore =
        coworkEngineStoreMap &&
        coworkEngineStoreMap.getPlateSetStore(coworkEngineNewPlateKey);
      coworkPlateSetStore &&
        coworkPlateSetStore.setState({ showNewPlate: true, createOrEdit: 0 });
    }
  };

  onEndDateChange = (v) => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    coworkNewStore.setCreateState({ dateValue: v });
  };

  getSearchs = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { createForm, newCoworkStatus } = coworkNewStore;
    const {
      createCondition,
      createList,
      selectValue,
      associateList,
      dateValue,
      createOrEdit,
    } = toJS(newCoworkStatus);
    const { isFormInit } = createForm;
    let group = [];
    const formParams = createForm.getFormParams();
    const isAnonymous =
      (associateList &&
        associateList.length > 0 &&
        associateList.filter(v => v.key == selectValue)[0] &&
        associateList.filter(v => v.key == selectValue)[0].isAnonymous) ||
      '0';
    const allowInvite =
      (associateList &&
        associateList.length > 0 &&
        associateList.filter(v => v.key == selectValue)[0] &&
        associateList.filter(v => v.key == selectValue)[0].allowInvite) ||
      '0';
    isFormInit &&
      createCondition &&
      createCondition.map((c) => {
        let items = [];
        c.items.map((fields) => {
          items.push({
            com: (
              <WeaFormItem
                ecId={`${
                  (this && this.props && this.props.ecId) || ''
                }_WeaFormItem@uxfzj0@${fields.domkey[0]}`}
                label={`${fields.label}`}
                labelCol={{ span: `${fields.labelcol}` }}
                wrapperCol={{ span: `${fields.fieldcol}` }}
                error={createForm.getError(fields)}
                tipPosition="bottom"
                viewAttr={fields.viewAttr}
              >
                {fields.domkey[0] == 'typeId' ? (
                  <div style={{ width: 373 }}>
                    <WeaSelect
                      ecId={`${
                        (this && this.props && this.props.ecId) || ''
                      }_WeaSelect@g2p9qt@${fields.domkey[0]}`}
                      hasAddBtn={fields.otherParams.hasAddBtn}
                      options={createList}
                      value={selectValue}
                      onChange={this.onTypIdChange}
                      addOnClick={this.onTypeIdAddClick}
                      viewAttr={fields.viewAttr}
                      helpfulTip={
                        createOrEdit == 0
                          ? getLabel(
                              '525087',
                              '协作保存后，只有协作所属版块的版块负责人或版块创建人可修改',
                            )
                          : ''
                      }
                      className={classname(
                        'cowork-typeId',
                        fields.otherParams.hasAddBtn ? 'coworkAddbtn' : '',
                      )}
                    />
                  </div>
                ) : fields.domkey == 'endDate' ? (
                  <WeaDatePicker
                    ecId={`${
                      (this && this.props && this.props.ecId) || ''
                    }_WeaDatePicker@jci8op@${fields.domkey[0]}`}
                    value={dateValue}
                    showTime
                    format="yyyy-MM-dd HH:mm"
                    placeholder={
                      getLabel(83869, '请输入') + getLabel(743, '结束时间')
                    }
                    style={{ width: '100%' }}
                    onChange={this.onEndDateChange}
                  />
                ) : (
                  <WeaSwitch
                    ecId={`${
                      (this && this.props && this.props.ecId) || ''
                    }_WeaSwitch@14z0vg@${fields.domkey[0]}`}
                    fieldConfig={fields}
                    form={createForm}
                    formParams={formParams}
                  />
                )}
              </WeaFormItem>
            ),
            colSpan: 1,
            hide: createForm.isHide(fields, () => {
              let bool = false;
              fields.domkey[0] === 'isAnonymous' &&
                isAnonymous == 0 &&
                (bool = true);
              fields.domkey[0] === 'allowInvite' &&
                allowInvite == 0 &&
                (bool = true);
              return bool;
            }),
          });
        });
        group.push(
          <WeaSearchGroup
            ecId={`${
              (this && this.props && this.props.ecId) || ''
            }_WeaSearchGroup@a65ph7@searchgroup`}
            col={1}
            center
            needTigger={true}
            title={getLabel(1361, '基本信息')}
            showGroup={true}
            items={items}
          />,
        );
      });
    return group;
  };

  getBaseInfo = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );

    let {
      accessoryPath,
      itemsVO,
      createOrEdit,
      editCoworkInfo,
      selectedKey,
    } = toJS(coworkNewStore.newCoworkStatus);
    if (createOrEdit == 1 && editCoworkInfo) {
      // 点击编辑按钮--编辑协作数据
      itemsVO = toJS(this.props.coworkMainStore.content.cowork.itemsVO);
    }

    // 取新建协作默认带入的客户，项目等
    let { appDataByType } = toJS(coworkNewStore.config);
    let relatedcusList = [
      ...(itemsVO.relatedcusList === undefined ? [] : itemsVO.relatedcusList),
      ...(appDataByType.get('crm') === undefined
        ? []
        : appDataByType.get('crm')),
    ];
    let relatedprjList = [
      ...(itemsVO.relatedprjList === undefined ? [] : itemsVO.relatedprjList),
      ...(appDataByType.get('task') === undefined
        ? []
        : appDataByType.get('task')),
    ];
    let relateddocList = [
      ...(itemsVO.relateddocList === undefined ? [] : itemsVO.relateddocList),
      ...(appDataByType.get('doc') === undefined
        ? []
        : appDataByType.get('doc')),
    ];
    let relatedwfList = [
      ...(itemsVO.relatedwfList === undefined ? [] : itemsVO.relatedwfList),
      ...(appDataByType.get('workflow') === undefined
        ? []
        : appDataByType.get('workflow')),
    ];
    let mutil_prjsList = [
      ...(itemsVO.mutil_prjsList === undefined ? [] : itemsVO.mutil_prjsList),
      ...(appDataByType.get('project') === undefined
        ? []
        : appDataByType.get('project')),
    ];

    return (
      <div
        style={{
          height: '100%',
          paddingBottom: createOrEdit == 1 ? 47 : 0,
          display: selectedKey == 0 ? 'block' : 'none',
        }}
      >
        {this.getSearchs()}
        <WeaSearchGroup
          ecId={`${
            (this && this.props && this.props.ecId) || ''
          }_WeaSearchGroup@ju16z9`}
          title={getLabel(16284, '详细说明')}
          col={1}
          needTrigger={true}
          showGroup={true}
          items={[
            {
              com: (
                <CoworkRichText
                  ecId={`${
                    (this && this.props && this.props.ecId) || ''
                  }_CoworkRichText@iib8px@richtext`}
                  ref="rich"
                  richValue={itemsVO && itemsVO.remark}
                  relatedprjList4E9={itemsVO && relatedprjList}
                  relatedcusList4E9={itemsVO && relatedcusList}
                  relateddocList4E9={itemsVO && relateddocList}
                  relatedwfList4E9={itemsVO && relatedwfList}
                  relatemutilprjs4E9={itemsVO && mutil_prjsList}
                  relatedaccList4E9={itemsVO && itemsVO.relatedaccList}
                  accessoryPath={accessoryPath}
                  startupFocus={false}
                />
              ),
            },
          ]}
        />
      </div>
    );
  };

  onSelectChange = (selectedRowKeys, selectedRows) => {
    let selectQuit = selectedRows.map(v => v.userid);
    this.setState({ selectQuit });
  };

  renderQuit = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const rowSelection = {
      onChange: this.onSelectChange,
    };
    return (
      <WeaTable
        ecId={`${
          (this && this.props && this.props.ecId) || ''
        }_WeaTable@7aw28d`}
        comsWeaTableStore={coworkNewStore.quitTable}
        rowSelection={rowSelection}
        hasOrder
        needScroll
      />
    );
  };

  getBtns = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { selectedKey, createOrEdit, saveLoading, saveSetLoading } = toJS(
      coworkNewStore.newCoworkStatus,
    );
    const quitChoose = toJS(coworkNewStore.quitTable.selectedRowKeys).length;
    let btns = [];
    if (selectedKey == 0) {
      btns.push(
        <Button
          ecId={`${
            (this && this.props && this.props.ecId) || ''
          }_Button@nimsr3@save`}
          type="primary"
          loading={saveLoading}
          onClick={() => this.onRightMenuClick('BTN_SAVE')}
        >
          {getLabel(86, '保存')}
        </Button>,
      );
      createOrEdit == 0 &&
        btns.push(
          <Button
            ecId={`${
              (this && this.props && this.props.ecId) || ''
            }_Button@vzuhkn@todetail`}
            type="primary"
            loading={saveSetLoading}
            onClick={() => this.onRightMenuClick('BTN_SAVESET')}
          >
            {getLabel(32159, '保存并进入详细设置')}
          </Button>,
        );
    }
    if (selectedKey == 2) {
      btns.push(
        <Button
          ecId={`${
            (this && this.props && this.props.ecId) || ''
          }_Button@j7vyb3@rejoin`}
          type="primary"
          disabled={quitChoose === 0}
          onClick={this.onReJoin}
        >
          {getLabel('513243', '重新加入协作')}
        </Button>,
      );
    }
    return btns;
  };

  onReJoin = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { reJoinCoworkQuiter } = coworkNewStore;
    const { selectQuit } = this.state;
    const {
      coworkMainStore: { reloadLeftList, reloadCowork },
    } = this.props;
    confirm({
      content: getLabel('513246', '确定要将选中人员重新加入协作吗？'),
      okText: getLabel(83446, '确定'),
      onOk() {
        let quiterIds = selectQuit.join();
        reJoinCoworkQuiter({ quiterIds }, () => {
          reloadLeftList();
          reloadCowork();
        });
      },
    });
  };

  getRightMenu() {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { newCoworkStatus } = coworkNewStore;
    const { createOrEdit, selectedKey } = toJS(newCoworkStatus);
    let btnArr = [];
    if (selectedKey == 0) {
      btnArr.push({
        key: 'BTN_SAVE',
        icon: <i className="icon-coms-Preservation" />,
        content: `${getLabel(86, '保存')}`,
        onClick: () => this.onRightMenuClick('BTN_SAVE'),
      });

      createOrEdit == 0 &&
        btnArr.push({
          key: 'BTN_SAVESET',
          icon: <i className="icon-coms-Flow-setting" />,
          content: `${getLabel(32159, '保存并进入详细设置')}`,
          onClick: () => this.onRightMenuClick('BTN_SAVESET'),
        });
    } else {
      btnArr.push({
        key: 'BTN_LOG',
        icon: <i className="icon-coms-Print-log" />,
        content: `${getLabel(83, '日志')}`,
        onClick: () => this.onRightMenuClick('BTN_LOG'),
      });
    }
    return btnArr;
  }

  // 检测是否将自己移除了负责人
  onCheckPrincipal = (type, params, cb) => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { onCheckPrincipal, createForm, newCoworkStatus } = coworkNewStore;
    const formParams = createForm.getFormParams();
    const principal_params = {
      principal: formParams.principal,
      id: newCoworkStatus.editId,
    };
    onCheckPrincipal(principal_params).then((res) => {
      const needChange = res.authorityChange;
      if (needChange) {
        const that = this;
        Modal.confirm({
          title: '',
          content: getLabel(
            '524521',
            '保存后将失去对该主题的维护权限，确定要保存吗？',
          ),
          onOk() {
            that.onEditSubmit(type, params, cb);
          },
        });
      } else {
        this.onEditSubmit(type, params, cb);
      }
    });
  };

  onEditSubmit = (type, params, cb) => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    let _type = type == 'editSave' ? 'editSave' : 'create';
    let needCbDelay = this.props.needCbDelay;
    coworkNewStore.saveorupdateCoworkItemVo(
      params,
      _type,
      () => {
        if (cb && typeof cb === 'function') cb();
        if (this.props.saveCallback) this.props.saveCallback(); // 为外部调用 提供回调
      },
      needCbDelay,
    );
  };

  onRightMenuClick = (type, cb) => {
    // cb 暂时只为保存提供回调
    if (type == 'BTN_LOG') {
      // 日志
      this.setState({ showLog: true });
    } else {
      const coworkNewStore = this.props.coworkStoreMap.getMapStore(
        this.props.storeMapKey,
      );
      const { createForm, newCoworkStatus } = coworkNewStore;
      let {
        createOrEdit,
        editId,
        dateValue,
        selectValue /* , createList */,
      } = toJS(newCoworkStatus);
      const formParams = createForm.getFormParams();
      // 负责人最多5人
      if (formParams.principal) {
        const princArr = formParams.principal.split(',');
        if (princArr.length > 5) {
          Modal.warning({
            title: '',
            content: getLabel('525416', '协作负责人最多可选择5人，请重新确认负责人'),
          });
          return;
        }
      }

      const rich = this.refs.rich.wrappedInstance;
      const richParams = rich.getSubmitParams();
      const params = {
        ...formParams,
        isApply: Number(formParams.isApply) || 0, // isApply数据库存的是int
        endDate: dateValue, // 结束时间
        typeId: selectValue, // 版块
        operationType: createOrEdit == 0 ? 'add' : 'edit',
        id: createOrEdit == 0 ? '' : editId,
        relatedPrj: richParams.relatedprj,
        relatedCus: richParams.relatedcus,
        relatedWf: richParams.relatedwf,
        relatedDoc: richParams.relateddoc,
        projectIds: richParams.projectIDs,
        relatedAcc: richParams.relatedacc,
        remark: rich.getRichData(),
      };

      if (type == 'BTN_SAVE' || type == 'editSave') {
        // 保存, editSave => 编辑--保存内容并跳转
        if (createOrEdit != 0) {
          // 编辑保存需要校验当前版块当事人是否还有权限（历史数据版块，后续被删除权限取不到版块的情况)
          // let typeright = true;
          // for (let i = 0; i < createList.length; i++) {
          //   if (createList[i].key == selectValue) {
          //     typeright = true;
          //     break;
          //   } else {
          //     typeright = false;
          //   }
          // }
          // if (!typeright) {
          //   message.error(
          //     getLabel(
          //       518263,
          //       '您已无当前版块权限，请选择新的版块，或者请联系系统管理员。',
          //     ),
          //   );
          //   return;
          // }
        }

        CoworkUtil.onCheck(createForm, () => {
          this.onCheckPrincipal(type, params, cb);
        });
      }
      if (type == 'BTN_SAVESET') {
        // 保存并进入详细设置
        CoworkUtil.onCheck(createForm, () => {
          coworkNewStore.saveorupdateCoworkItemVo(params, 'saveSet');
        });
      }
    }
  };

  onAddAuth = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    coworkNewStore.setCreateState({ showAuth: true });
  };

  onDelAuth = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { editId, selectValue } = coworkNewStore.newCoworkStatus;
    const selectedRowKeys = toJS(coworkNewStore.createTable.selectedRowKeys);
    CoworkUtil.doConfirm(getLabel(82017, '确认删除？'), () =>
      coworkNewStore.saveorupdateCoworkShare({
        id: editId,
        typeId: selectValue,
        shareId: selectedRowKeys.join(','),
      }),
    );
  };

  getTabBtns = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { selectedKey } = coworkNewStore.newCoworkStatus;
    const selectedRowKeys = toJS(coworkNewStore.createTable.selectedRowKeys);
    let btns =
      selectedKey != 1
        ? []
        : [
            <WeaButtonIcon
              ecId={`${
                (this && this.props && this.props.ecId) || ''
              }_WeaButtonIcon@0lsvli@add`}
              buttonType="add"
              type="primary"
              onClick={this.onAddAuth}
            />,
            <WeaButtonIcon
              ecId={`${
                (this && this.props && this.props.ecId) || ''
              }_WeaButtonIcon@2tbuzy@del`}
              buttonType="del"
              type="primary"
              disabled={selectedRowKeys.length == 0}
              onClick={this.onDelAuth}
            />,
          ];
    return btns;
  };

  onOperatesClick = (record, index, operate) => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { editId } = coworkNewStore.newCoworkStatus;
    if (operate.index == 0) {
      // 删除
      CoworkUtil.doConfirm(getLabel(82017, '确认删除？'), () =>
        coworkNewStore.saveorupdateCoworkShare({
          id: editId,
          shareId: record.id,
        }),
      );
    }
  };

  onTabChange = (v) => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { getQuitList, coworkShareList } = coworkNewStore;
    const { editId } = coworkNewStore.newCoworkStatus;
    if (v == 2) {
      // 已退出人员
      getQuitList();
    }
    if (v == 1) {
      let params = { coworkId: editId };
      coworkShareList(params);
    }
    coworkNewStore.setCreateState({ selectedKey: v });
  };

  onDialogCancel = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    coworkNewStore.setCreateState({ showNewCowork: false });
    coworkNewStore.doCreateFormInit();
    this.props.onCancel && this.props.onCancel();
  };

  saveCallBack = () => {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    coworkNewStore.getNewMyCoworkTypeList();
  };
  onLogViewCancel = () => this.setState({ showLog: false });

  render() {
    const coworkNewStore = this.props.coworkStoreMap.getMapStore(
      this.props.storeMapKey,
    );
    const { coworkMainStore: { content } } = this.props;
    const { logStore, status, topTab, topTitle, pageState } = coworkNewStore;
    const { logType, logSmallType } = toJS(status);
    const {
      createOrEdit,
      selectedKey,
      showNewCowork,
    } = coworkNewStore.newCoworkStatus;
    const CreatePlat =
      (window.weaCoworkEngine &&
        window.weaCoworkEngine.com &&
        window.weaCoworkEngine.com.CreatePlat) ||
      React.Fragment;
    const collectParams = {
      favname: topTitle,
      favouritetype: 1,
      objid: 0,
      link: 'wui/index.html#/main/cowork/main',
      importantlevel: 1,
    };
    const defaultTypeId = (content.cowork && content.cowork.itemsVO && content.cowork.itemsVO.typeid) || '';

    return (
      <div>
        <WeaDialog
          ecId={`${
            (this && this.props && this.props.ecId) || ''
          }_WeaDialog@ttdvjk`}
          style={{ width: 800, height: 565 }}
          visible={showNewCowork}
          title={topTitle}
          icon={CoworkConstant.iconClassName}
          iconBgcolor={CoworkConstant.iconBgColor}
          className="wea-cowork-new"
          hasScroll={createOrEdit == 0}
          onCancel={this.onDialogCancel}
          bottomLeft={
            selectedKey == 1 ? (
              <p style={{ color: 'red' }}>
                {getLabel(
                  '513665',
                  '注意：已退出人员请在已退出人员列表重新加入',
                )}
              </p>
            ) : (
              ''
            )
          }
          buttons={this.getBtns()}
          moreBtn={{
            datas: this.getRightMenu(),
            collectParams,
          }}
        >
          <WeaRightMenu
            ecId={`${
              (this && this.props && this.props.ecId) || ''
            }_WeaRightMenu@2nod3y`}
            datas={this.getRightMenu()}
            collectParams={collectParams}
          >
            {createOrEdit == 0 ? (
              this.getBaseInfo()
            ) : (
              <div style={{ height: '100%', position: 'relative' }}>
                <WeaTab
                  ecId={`${
                    (this && this.props && this.props.ecId) || ''
                  }_WeaTab@w1smgd`}
                  datas={topTab}
                  keyParam="viewcondition"
                  countParam="groupid"
                  selectedKey={selectedKey}
                  buttons={pageState !== '1' ? this.getTabBtns() : []}
                  onChange={this.onTabChange}
                />
                <div className="wea-cowork-new-content">
                  <WeaNewScroll
                    ecId={`${
                      (this && this.props && this.props.ecId) || ''
                    }_WeaNewScroll@kxnp2w`}
                    height="100%"
                  >
                    {this.getBaseInfo()}
                    {selectedKey == 1 && (
                      <WeaTable
                        ecId={`${
                          (this && this.props && this.props.ecId) || ''
                        }_WeaTable@cs82xz`}
                        comsWeaTableStore={coworkNewStore.createTable}
                        hasOrder={true}
                        needScroll={true}
                        onOperatesClick={this.onOperatesClick}
                      />
                    )}
                    {selectedKey == 2 && this.renderQuit()}
                    {selectedKey === '3' && (
                      <DefalutJoiner
                        ecId={`${
                          (this && this.props && this.props.ecId) || ''
                        }_DefalutJoiner@hwiez0`}
                        storeMapKey={this.props.storeMapKey}
                        defaultTypeId={defaultTypeId}
                        isReadOnly={pageState === '1'}
                      />
                    )}
                  </WeaNewScroll>
                </div>
              </div>
            )}
          </WeaRightMenu>

          <NewAuth
            ecId={`${
              (this && this.props && this.props.ecId) || ''
            }_NewAuth@xapyu4`}
            storeMapKey={this.props.storeMapKey}
          />
          {coworkNewStore.loaded &&
            window.weaCoworkEngine &&
            window.weaCoworkEngine.com &&
            window.weaCoworkEngine.com.CreatePlat && (
              <CreatePlat
                ecId={`${
                  (this && this.props && this.props.ecId) || ''
                }_CreatePlat@hpv3sv`}
                storeMapKey={coworkEngineNewPlateKey}
                saveCallBack={this.saveCallBack}
              />
            )}
        </WeaDialog>
        <WeaLogViewComp
          ecId={`${
            (this && this.props && this.props.ecId) || ''
          }_WeaLogViewComp@7titks`}
          visible={this.state.showLog}
          onCancel={this.onLogViewCancel}
          logStore={logStore}
          logType={logType}
          logSmallType={logSmallType}
          targetId={this.state.targetId}
        />
      </div>
    );
  }
}
